﻿Imports System.Text.RegularExpressions

Public Class DicHTML
    Public mdescription As String
    Public Property ShowDetailsDic() As String
        Set(ByVal Value As String)
            mdescription = Value
        End Set
        Get
            ShowDetailsDic = mdescription
        End Get
    End Property

    Public Sub LoadHTML(ByVal nameWeb As WebBrowser, ByVal fileHTML As String)
        ' Load 1 file HTML len web
        Dim sysURL As New System.UriKind
        Dim oFile As System.IO.File ' Read text file
        Dim fileExits As Boolean

        fileExits = oFile.Exists(fileHTML) ' Kiem tra file co ton tai
        If fileExits = True Then
            nameWeb.Url = New System.Uri(fileHTML, sysURL.Absolute)
        Else
            MsgBox("Err 02: Article for words has broken!", MsgBoxStyle.Exclamation, "Alarm")
        End If
    End Sub

    Public Sub StartDict(ByVal nameWeb As WebBrowser)
        ' Doc file StrartDict
        Dim oFile As System.IO.File ' Read text file
        Dim oDir As System.IO.Directory
        Dim sCurrentDir, sDir As String
        Dim fileExits As Boolean
        Dim lastFile As String

        sCurrentDir = CurDir()
        ' Load file last.dbn
        lastFile = sCurrentDir & "\data\about.html"
        sDir = sCurrentDir & "\data"
        If oDir.Exists(sDir) = False Then
            oDir.CreateDirectory(sDir)
        End If
        fileExits = oFile.Exists(lastFile) ' Kiem tra file co ton tai
        If fileExits = True Then
            LoadHTML(nameWeb, lastFile)
        End If
    End Sub

    Function StripTags(ByVal html As String) As String
        ' Remove HTML tags.
        Return Regex.Replace(html, "<.*?>", "")
    End Function
End Class
